package org.atlantis.evnlib.execution;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class UnnamedThreadFactory implements ThreadFactory {

	private String unNamed;
	private ThreadFactory defaultFactory = Executors.defaultThreadFactory();

	public static UnnamedThreadFactory create(String unNamed) {
		return new UnnamedThreadFactory(unNamed);
	}

	private UnnamedThreadFactory(String unNamed) {
		this.unNamed = unNamed;
	}

	@Override
	public Thread newThread(Runnable r) {
		Thread t = defaultFactory.newThread(r);
		t.setName(unNamed);
		return t;
	}
}
